export type GetApiRepoChannelNameCkeyArgs = {channel_name: string, ckey: unknown, sbom?: ('view' | 'download') | undefined}; export type GetApiRepoChannelNameCkeyOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get artifact contents or other information * * GET /repo/{channel_name}/{ckey:[^/].*?} */ export const getApiRepoChannelNameCkey = async (args: GetApiRepoChannelNameCkeyArgs, options?: GetApiRepoChannelNameCkeyOptions) => { const {baseUrl = "https://api.anaconda.cloud/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.sbom != null) query.append("sbom", String(args.sbom)) const url = `${baseUrl.replace(/\/+$/, '')}/repo/${encodeURIComponent(String(args.channel_name))}/${encodeURIComponent(String(args['ckey:[^/].*?']))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };